import * as api from '@/api/article';

export default {
  namespaced: true,
  state: {
    articleDetail: {},
    commentList: [],
  },
  mutations: {
    setArticleDetail (state, newValue) {
      state.articleDetail = newValue;
    },
    setCommentList (state, newValue) {
      state.commentList = newValue;
    },
  },
  actions: {
    async updateArticleDetail (ctx, id) {
      const res = await api.getArticleDetail(id);
      ctx.commit('setArticleDetail', res);
    },
    async updateCommentList (ctx, id) {
      const res = await api.getCommentList(id);
      ctx.commit('setCommentList', res);
    },
  },
}
